//
//  DetailViewController.m
//  DouBan
//
//  Created by lanou3g on 15/8/8.
//  Copyright (c) 2015年 xuzheng. All rights reserved.
//

#import "DetailViewController.h"
#import "DataTool.h"
#import "MoviesViewController.h"
#import "Movies.h"
@interface DetailViewController ()

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIBarButtonItem *left=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"90-lifebuoy.png"] style:UIBarButtonItemStyleDone target:self action:@selector(leftAction)];
    self.navigationItem.leftBarButtonItem=left;
    
    UIBarButtonItem *right=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"27-planet.png"] style:UIBarButtonItemStyleDone target:self action:@selector(rightAction)];
    self.navigationItem.rightBarButtonItem=right;
    
    //详细解析
    NSString *urls=@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/searchmovie.php?movieId=216609";
    [DataTool solveDataWithURL:urls andMethod:@"GET" andBody:nil andBlock:^(NSData *data) {
        NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@",dic);
        self.data=[NSMutableArray array];
        NSArray *arr = dic[@"events"];
        for (NSDictionary *dict in arr) {
            Movies *mov = [[Movies alloc]init];
            [mov setValuesForKeysWithDictionary:dict];
            [self.data addObject:mov];
        }
        for (Movies *m in self.data) {
            NSLog(@"%@---%@", m.pic_url,m.movieName);
        }
        
 }];
    // Do any additional setup after loading the view.
}


- (void)leftAction{
    
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)rightAction{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
